#ifndef __VTY_IPC_MSG_HPP__
#define __VTY_IPC_MSG_HPP__ 

#include "khan.hpp"
#include "ipc_message.hpp"


typedef enum 
{
    VTY_ADD_MODE,       VTY_ADD_CMD,    
    VTY_EXEC_FUNC,
    VTY_IS_AUTH_MODE,   VTY_SET_BANNER,     VTY_GET_BANNER, /* 5 */
    VTY_CHECK_PW,       VTY_CUR_MODE,       VTY_CHG_MODE,       
    VTY_IS_DIAG,        VTY_START_DIAG,     VTY_STOP_DIAG,  VTY_DIAG_MSG,   /* 12 */
    VTY_EXEC_PTY,       VTY_OUTPUT, 
	VTY_ALARM,	VTY_RUN_CFG,
    VTY_MAX_CMD
} vty_cmd_t;

typedef enum { VTY_RET_NONE, VTY_FAIL, VTY_SUCC, VTY_TRUE, VTY_FALSE } vty_sub_cmd_t;
//typedef enum { VTY_INT_16, VTY_INT_32, VTY_INT_64, VTY_STRING } vty_arg_t;

struct vty_msg_hdr_t
{
    __u32   _vty_id;
    __u32   _cmd;
    __u32   _sub_cmd;
    __u32   _size;
};

typedef vty_msg_hdr_t vty_ipc_hdr_t;
typedef ipc_message vty_ipc_message_t;
typedef ipc_message vty_ipc_opt_t;

#define VTY_MAX_IPC_BODY_SIZE 	\
	(ipc_message::max_body_length \
	- (ipc_message::header_length + sizeof(struct vty_msg_hdr_t)))

typedef struct vty_remote_function_id
{
    __u64 _agent_id;
    __u64 _function_id;
} vty_remote_function_id_t;

/* FIXME: more the effiective !! */
class vty_ipc_msg
{
public:
    vty_ipc_msg() {};

    void build_msg(__u32 vty_id, __u32 cmd, __u32 sub, 
            const string_vector& opts, vty_ipc_message_t& msg);
    void build_msg(__u32 vty_id, vty_cmd_t cmd, vty_sub_cmd_t sub, 
            const string_vector& opts, vty_ipc_message_t& msg);
    int parse_msg(vty_ipc_message_t& msg, __u32& vty_id, __u32& cmd, 
            __u32& sub, string_vector& opts);

    void encode_msg(vty_ipc_message_t& msg);
    void decode_msg(vty_ipc_message_t& msg);

private:
    void decode_header(vty_msg_hdr_t& hdr);
    void encode_header(vty_msg_hdr_t& hdr);
};

#endif
